package com.to_door_recycle.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.to_door_recycle.model.pojo.User;
import com.to_door_recycle.dao.IUserDao;
import com.to_door_recycle.mapper.UserMapper;
import org.springframework.stereotype.Service;

/**
* @author 30793
* @description 针对表【users(用户表)】的数据库操作Service实现
* @createDate 2024-10-14 15:30:28
*/
@Service
public class UserDao extends ServiceImpl<UserMapper, User>
    implements IUserDao {

    public User selectByUsername(String username) {
        return getOne(new LambdaQueryWrapper<User>().eq(User::getUsername, username));
    }

    @Override
    public User selectByPhoneAndPassword(String phone, String password) {
        return getOne(new LambdaQueryWrapper<User>().eq(User::getPhone, phone).eq(User::getPassword, password));
    }

    @Override
    public User selectByUsernameAndPassword(String username, String password) {

        return getOne(new LambdaQueryWrapper<User>().eq(User::getUsername, username).eq(User::getPassword, password));
    }

    @Override
    public User selectByPhone(String phone) {
        return getOne(new LambdaQueryWrapper<User>().eq(User::getPhone, phone));
    }

    @Override
    public User selectByOpenId(String openId) {
        return getOne(new LambdaQueryWrapper<User>().eq(User::getOpenid, openId));
    }
}




